package com.hong.config.factory;

import com.hong.config.parse.Parser;
import com.hong.config.parse.PropertiesParser;
import com.hong.qrpc.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author HQT
 * @Date 2022/7/15 17:40
 */
@Slf4j
public class ParserFactory {
    public static Parser getParser(String suffix) {
        if(StringUtils.isEmpty(suffix)){
            log.error("This file type cannot be parsed");
            throw new IllegalArgumentException("not support parsing this type of file");
        }
        switch (suffix){
            case ".properties":
                return new PropertiesParser();
            default:
                log.error("This file type cannot be parsed");
                throw new IllegalArgumentException("not support parsing this type of file");
        }
    }
}
